﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HBMDoc.util
{
    class UtilData
    {

        /**
         * 创建dict
         */ 
        public static Dictionary<K, V> make<K, V>(params Object[] objects)
        {
            if ((objects.Count() % 2) != 0)
            {
                throw new ArgumentException("参数数量必须是2的倍数");
            }

            Dictionary<K, V> dict = new Dictionary<K, V>();
            for (int i = 0; i < objects.Count(); i = i + 2)
            {
                dict.Add((K)objects[i], (V)objects[i + 1]);
            }

            return dict;
        }

        public static JObject CreateJson(params Object[] objects)
        {

            if ((objects.Count() % 2) != 0)
            {
                throw new ArgumentException("参数数量必须是2的倍数");
            }

            JObject jobject = new JObject();
            for (int i = 0; i < objects.Count(); i = i + 2)
            {
                jobject.Add(objects[i].ToString(), objects[i + 1].ToString());
            }

            return jobject;
        }



    }
}
